package Util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Util {

	/**
	 * Testing Internet connexion
	 * 
	 * @param c Context where we want to test internet connexion
	 * 
	 * @return true if a connexion is available, else false.
	 */
	
	public static boolean isOnline(Context c) {

		Boolean connected = true;
		ConnectivityManager cm = (ConnectivityManager) c
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo networkInfo = cm.getActiveNetworkInfo();
		connected = networkInfo != null && networkInfo.isAvailable()
				&& networkInfo.isConnected();
		return connected;
	}
	
}